Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • kososki 8 posts 28 karma points
    May 29, 2014 @ 09:16
    kososki
    0

    [v7.1] Back Office Media Tree shows each element twice

    Hi everyone,

    I wrote a code that after adding new content in Back Office automatically create folder with the same name in Media Tree.

    Everything looks fine but there is a small problem how media are displayed in Media Tree.

    E.x.
    I create a new Content  called 'Root' so during the SaveEvent I'm creating media folder with the same name, add to media folder's properties the Id of related content. After I saved Media folder I add its Id to the content's properties.
    I debugged it many times and it looks ok, but after I refresh Media Tree I see each element twice. It's the same element, when I click on the second duplicate, the first one is highlighted. Below I paste piece of code that is responsible for creating appropriate media folder.

    Anyone can help ?

    I have second question about refreshing media tree from the code (C#). After I add this media folder programatically I would like to refresh the media without clicking F5.

    Regards
    T

    string name = content.Name;
                            int mediaParentId = -1;

                            if (content.ParentId > 0)
                            {
                                var prop = content.Parent().Properties.FirstOrDefault(p=>p.Alias == "afxMediaFolderId");
                                if (prop != null)
                                {
                                    Int32.TryParse(prop.Value.ToString(), out mediaParentId);
                                }
                            }

                            IMedia media = CreateMedia(name, mediaParentId, "Folder", content.Id);

                            var cprop = content.Properties.FirstOrDefault(p => p.Alias == "afxMediaFolderId");
                            if (cprop != null)
                            {
                                cprop.Value = media.Id;
                                ContentService.Save(content);
                            }

     

  • kososki 8 posts 28 karma points
    May 29, 2014 @ 11:20
    kososki
    0

    OK, I handle with duplicates but still have problem with refreshing media tree from code

    Any help in this case ?

    Regards

Please Sign in or register to post replies

Write your reply to:

Draft